<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
	.table_box {
	}
</style>
</head>

<body>
	<div class="page_header">
	<div class="table_tool">
		<ul class="clearfix">			
			<li class="couponDel btn"><i class="icon-remove"></i> 批量删除</li>
			<li class="line"></li>
			<li class="couponAdd btn"><i class="icon-plus"></i> 新增优惠券</li>
			<li class="line"></li>
		</ul>
	</div>
	<div class="search_box">
		会员分组：
		<select id="cus_groupid" style="width:11%;height:100%;">
			<option value="">请选择</option>
			<volist name="details" id="vo">
				<option value="{$vo.id}">{$vo.title}</option>
				<!-- <li rel="{$vo.id}" title="{$vo.title}"><i class="icon-caret-right"></i>{$vo.title}</li> -->
			</volist>
			
		</select>
		会员卡号：<input type="text" id="vipno" class="form_ele w100"/>
		手机号码：<input type="text" id="mobile" class="form_ele w100"/>
		会员姓名：<input type="text" id="realname" class="form_ele w100"/>
		<span id="doSearch" class="doSearch">
			<i class="icon-search"></i> 搜索
		</span>
	</div>
	
	</div>
	<div class="table_box">
	</div>
</body>
<script type="text/javascript">
	var listConfig = {
			gridId : 'memberList',
			blockBox : '.table_box',
			blockBoxHeight : 'window',
			jsonUrl : '__URL__/index',
			where : '',
	 		getWhere : function(){
				var vipno     = $('#vipno').val();
				var mobile    = $('#mobile').val();
				var realname  = $('#realname').val();
				return where;
			},
			
			widthType : 'tdw', //thw-标题标准宽度、tdw-数据单元标准宽度、auto-随数据单元宽度
			pageNum : 10,
			nowPage : 1,
			orderName : "addtime",
			orderDirection : "desc",
			dataContextMenuOpen: true, //是否开启数据行右键菜单
			dataContextMenu: function(){
				$.contextMenu({
					selector: '.et_tbody tr',
					items: {
						"edit": {
							name: "修改", 
							icon: "edit",
							callback: function(key, options) {
								var href   = "{:U('Coupon/edit')}&id="+$(this).attr('rowid');
								var width  = '850px';
								var height = '420px';
								var title  = '修改会员';
								openDialog('Coupon_edit',href,width,height,title);
							}
						},
						"delete": {
							name: "删除", 
							icon: "edit",
							callback: function(key, options) {
								//var title =  $(this).children('td[fieldname="title"]').html();
								
								var id = $(this).attr('rowid');
								$.post("{:U('Custom/del')}",{id:id},function(data){
									$('.et_tfoot .page_refresh').click(); //刷新加载
								})
							}
						}
					}
				});
			},
			colModel : [
				{
					display : 'checkbox',
					name : 'id',
					sortable : false,
					myclass : 'center',
					edit : false
				},
				{
					display : '名称',
					name : 'title',
					sortable : true,
					myclass : 'center',
					edit : true
				},
				{
					display : '前缀',
					name : 'prefix',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				{
					display : '发放数量',
					name : 'total',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px',
				},
				{
					display : '类型',
					name : 'type',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				{
					display : '开始时间',
					name : 'begin',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px',
				},
				{
					display : '过期时间',
					name : 'end',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px',
				},
				{
					display : '启用',
					name : 'isshow',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px',
				},
				{
					display : '添加时间',
					name : 'addtime',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px',
				},
			]
		};
	
	//实例化列表
	var tableList = $('.table_box').EtGrid(listConfig);
	//tableList.erefresh();
	
	//搜索
 	$('#doSearch').on('click',function(){
		
		var where = tableList.config.getWhere();
		
		tableList.config.where = where;
		tableList.search();
	});
	
/* 	$('#doSearch').on('click',function(){
		
		var vipno     = $('#vipno').val();
		var mobile    = $('#mobile').val();
		var realname  = $('#realname').val();
		var groupid   = $('#cus_groupid').val();
		
		$.get("{:U('Custom/search')}",{vipno:vipno,mobile:mobile,realname:realname,groupid:groupid});
		
	}); */
	
	//添加优惠券
	$('.couponAdd').on('click',function(){
		var href   = "{:U('Coupon/add')}";
		var width  = '850px';
		var height = '420px';
		var title  = '新增优惠券';
		openDialog('Coupon_add',href,width,height,title);
	})
	
	//批量删除
	$('.memberDel').on('click',function(){
		
		var val = tableList.getChecked();
		var msg = "确认要将选中的会员删除吗？";
		
		if(val){
			windowApi.lhgdialog.confirm(msg, function(){
				$.post("{:U('Custom/del')}",{id:val},function(data){
					if(data.status==1){
						$('.et_tfoot .page_refresh').click(); //刷新加载
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){
				return;
			});
		}else{
			windowApi.lhgdialog.alert('请选择需要删除的会员！');
		}
	});
	
	$('.updateLevel .submenu>li').on('click',function(){
		var val = tableList.getChecked();
	}); 
	
	//打开统计图表
	$('.memberChart').on('click',function(){
		var href = 'memberAdd.html?id='+$(this).attr('rowid');
		var width = '900px';
		var height = '500px';
		var title = '统计图表';
		openDialog('memberChart',href,width,height,title);
	});
</script>
</html>
